import type { RequiredDeep } from 'type-fest'

import { ajax } from '@/utils'

import type { components } from '../schema'

/**
 * 在线接口
 */
export const onlineApi = {
  /**
   * 获取在线分页
   */
  getOnlinePage(data: IGetOnlinePageReq): Promise<IGetOnlinePageRes> {
    return ajax.post('/monitor/online/page', data)
  },
  /**
   * 下线
   */
  offline(id: string) {
    return ajax.delete('/monitor/online', { params: { id } })
  }
}

export type IGetOnlinePageReq = components['schemas']['FindOnlinePageDTO']
export type IGetOnlinePageRes = RequiredDeep<
  components['schemas']['FindOnlinePageVO']['data']
>
export type IOnlinePageItem = IGetOnlinePageRes['list'][0]
